package com.zhiwang.planet.ui.main.v2

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.zhiwang.planet.BuildConfig
import com.zhiwang.planet.R
import com.zhiwang.planet.ui.BaseFragment
import kotlinx.android.synthetic.main.fragment_money_v2.*

class MoneyFragmentV2 : BaseFragment() {


    private var titles = arrayOf(
            "游戏",
            "应用"
    )


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_money_v2, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)


        val taskFragment = childFragmentManager.findFragmentByTag("fasttask")
                ?: FastTaskFragment.newInstance()
        val gameFragment = childFragmentManager.findFragmentByTag("gamefragment")
                ?: GameFragment.newInstance()
//        val pokerFragment = childFragmentManager.findFragmentByTag("poker")
//                ?: PokerFragment.newInstance()

        if (BuildConfig.HIDE_TASK)
            titles = arrayOf(
                    "手游",
                    "棋牌"
            )

        if (BuildConfig.HIDE_TASK)
            slidingTabLayout.setViewPager(viewPager, titles, childFragmentManager,
                    arrayListOf(

                            gameFragment,
                            taskFragment
//                            pokerFragment
                    ))
        else {
            slidingTabLayout.setViewPager(viewPager, titles, childFragmentManager,
                    arrayListOf(
                            gameFragment,
                            taskFragment
                    ))
        }
    }

    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
    }

}